home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s1.arc
/
DEFINEKY.MOD
< prev
next >
Wrap
Text File
|
1987-05-16
|
7KB
|
153 lines
(*----------------------------------------------------------------------*)
(* Get_Key_Section --- Get section/offset of function key *)
(*----------------------------------------------------------------------*)
PROCEDURE Get_Key_Section( Key_Name : AnyStr;
VAR Key_Offset : INTEGER;
VAR Key_Number : INTEGER;
VAR Section_No : INTEGER );
(*----------------------------------------------------------------------*)
(* *)
(* Procedure: Get_Key_Section *)
(* *)
(* Purpose: Get section/offset for function/keypad key *)
(* *)
(* Calling Sequence: *)
(* *)
(* Get_Key_Section( Key_Name : AnyStr; *)
(* VAR Key_Offset : INTEGER; *)
(* VAR Key_Number : INTEGER; *)
(* VAR Section_No : INTEGER ); *)
(* *)
(* Key_Name --- Name of key *)
(* Key_Offset --- Offset of key within section *)
(* Key_Number --- Scan code of key *)
(* Section_No --- Section number of key *)
(* *)
(*----------------------------------------------------------------------*)
VAR
I: INTEGER;
J: INTEGER;
BEGIN (* Get_Key_Section *)
(* Evict blanks from key name *)
I := POS( ' ' , Key_Name );
WHILE ( I > 0 ) DO
BEGIN
DELETE( Key_Name, I, 1 );
I := POS( ' ' , Key_Name );
END;
Key_Name := UpperCase( Key_Name );
(* Get section number of key. *)
(* Check for miscellaneous guys *)
(* immediately. *)
FOR J := 1 TO No_Misc_Keys DO
IF ( Key_Name = Key_Definitions[Misc_Keys[J]].Name ) THEN
BEGIN
Section_No := 9;
Key_Number := Misc_Keys[J];
Key_Offset := Misc_Keys[J];
EXIT;
END;
(* Not a miscellaneous key -- *)
(* try others. *)
I := 2;
Key_Name := Key_Name + ' ';
Section_No := POS( Key_Name[1] , 'FSCAK N' );
IF ( Section_No = 6 ) THEN
Section_No := 0
ELSE IF ( Key_Name[2] = 'K' ) THEN
BEGIN
IF ( Section_No = 3 ) THEN
Section_No := 7
ELSE IF ( Section_No = 4 ) THEN
Section_No := 6;
I := 3;
END;
(* Get key number if section number OK *)
Key_Offset := 0;
Key_Number := -1;
IF ( Section_No > 0 ) THEN
CASE Key_Name[I] OF
'0'..'9': WHILE( Key_Name[I] IN ['0'..'9'] ) DO
BEGIN
Key_Offset := Key_Offset * 10 + ORD(Key_Name[I]) - ORD('0');
I := SUCC( I );
END;
'.' : Key_Offset := 10;
'-' : Key_Offset := 11;
'+' : Key_Offset := 12;
ELSE;
END (* CASE *)
ELSE
EXIT;
(* Can't have offset > 12 )
IF ( Key_Offset > 12 ) THEN
EXIT;
(* 0 not allowed in function *)
(* keys -- OK for top ALT keys *)
(* and keypad. *)
IF ( Key_Offset <= 0 ) THEN
IF ( Section_No < 5 ) THEN
EXIT;
CASE Section_No OF
1..4 : Key_Number := Key_Offset + Funk_Bases[ Section_No ];
5 : Key_Number := Keypad_Nos[ Key_Offset ] + 70;
6 : Key_Number := Keypad_Nos[ Key_Offset ] + 173;
7 : Key_Number := Ctrl_Keys[ Key_Offset ];
8 : Key_Number := Number_Nos[ Key_Offset ] + 119;
END (* CASE *);
END (* Get_Key_Section *);
(*----------------------------------------------------------------------*)
(* Define_Key --- Define a function/keypad key *)
(*----------------------------------------------------------------------*)
PROCEDURE Define_Key( Key_Name : AnyStr;
Key_Text : AnyStr );
(*----------------------------------------------------------------------*)
(* *)
(* Procedure: Define_Key *)
(* *)
(* Purpose: Defines a function/keypad key string *)
(* *)
(* Calling Sequence: *)
(* *)
(* Define_Key( Key_Name : AnyStr; *)
(* Key_Text : AnyStr ); *)
(* *)
(* Key_Name --- Name of key to define *)
(* Key_Text --- Text of key to be defined *)
(* *)
(*----------------------------------------------------------------------*)
VAR
Section_No : INTEGER;
Key_Offset : INTEGER;
Key_Number : INTEGER;
BEGIN (* Define_Key *)
Get_Key_Section( Key_Name, Key_Offset, Key_Number, Section_No );
(* Insert key text *)
IF ( Key_Number >= 0 ) THEN
WITH Key_Definitions[Key_Number] DO
BEGIN
IF ( Def = NIL ) THEN
NEW( Def );
Def^ := Read_Ctrls( Key_Text );
END;
END (* Define_Key *);